package com.xdf.service;

import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.client.ServiceInstance;
import org.springframework.cloud.client.discovery.DiscoveryClient;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author chanchaw
 * @create 2025-08-18 13:24
 */
@Slf4j
@RequiredArgsConstructor
@Service
public class NacosClientService {
    private final DiscoveryClient discoveryClient;

    // 获取指定微服务的所有实例信息
    public List<ServiceInstance> getNacosClientInfo(String serviceId){
        log.info("发现服务：[{}]",serviceId);
        return discoveryClient.getInstances(serviceId);
    }
}
